#ifndef PAGE2_CHUAN_H
#define PAGE2_CHUAN_H

#include "data_upup.h"

#include <QTime>
#include <QDebug>
#include <QObject>
#include <QWidget>
#include <QPainter>
#include <QErrorMessage>
#include <QtSerialPort/QSerialPort>             //提供访问串口的功能
#include <QtSerialPort/QSerialPortInfo>         //提供系统中存在的串口的信息



namespace Ui {
class page2;
}

class page2 : public QWidget
{
    Q_OBJECT

public:
    explicit page2(QWidget *parent = nullptr);

    void serialPort_Find();

    bool serialPort_Open();

    void serialPort_Close();

    void PortConfigure_Init();

    void Data_Read();

    void Data_Send();

    void Data_Send_upup(QByteArray data_send);

    void serialPort_Send(const char *data);

    void String2Hex(QString str,QByteArray &data);

    char convertHexChart(char ch);

    void Receive_Part_Clear();

    void Save();

    void Load();

    void Exit();

    Data_upup * data_upup;

    ~page2();

signals:
    void pushbutton_page1_clicked();

    void pushbutton_page2_clicked();

    void pushbutton_page3_clicked();

    void pushbutton_page4_clicked();

private slots:
    void on_pushButton_page1_clicked();

    void on_pushButton_page2_clicked();

    void on_pushButton_page3_clicked();

    void on_pushButton_page4_clicked();

private:
    Ui::page2 *ui;
    //串口通讯变量
    QSerialPort *serial;
    qint32 baud;
    //按钮变量
    bool Port_Open=false;
    int Receive_OverTime_Count=1;
};

#endif // PAGE2_CHUAN_H
